const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')


module.exports = {
  // 入口文件
  entry:{
    index:path.resolve(__dirname, './src/main.js')
  },
  output:{
    // 输出路径
    path:path.join(__dirname,'./dist'),
    // 输出
    filename:'[name].[hash:6].js'
  },
  module:{
    rules: [
      {
        test: /\.vue$/,
        use: 'vue-loader'
      },
      {
        test: /\.(css|less)?$/,
        use:["style-loader", "css-loader", "less-loader"]
      },
      {
        test: /\.(png|jpg|gif)$/,
        loader: 'file-loader',
        options: {
          // file-loader在新版本中(>4.2.0)esModule默认为true，因此手动设置为false
          esModule: false, // 这里设置为false
        }
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader'
        }
      }
    ]
  },
  plugins:[
    new HtmlWebpackPlugin({
      template:'./index.html'
    }),
    new VueLoaderPlugin()
  ]
}